package com.bite.product.controller;

import com.bite.product.model.ProductInfo;
import com.bite.product.service.ProductService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Yun
 * @Date: 2025/5/31
 */
@Slf4j
@RestController
@RequestMapping("/product")
public class ProductController {
    @Resource
    private ProductService productService;

    @RequestMapping("/{id}")
    public ProductInfo getProductById(@PathVariable Integer id) {
        log.warn("------------------------------------------------");
        return productService.selectProductById(id);
    }

    @RequestMapping("/p1")
    public String p1(@RequestParam("id") Integer id) {
        return "id :" + id;
    }

    @RequestMapping("/p2")
    public String p2(@RequestParam("id") Integer id, String name) {
        return "id :" + id + ", name :" + name;
    }

    @RequestMapping("/p3")
    public String p3(ProductInfo productInfo) {
        return productInfo.toString();
    }

    @RequestMapping("/p4")
    public String p4(@RequestBody ProductInfo productInfo) {
        return productInfo.toString();
    }
}
